package servlet;

/**
 * @author Lu Ruotong
 * @date 2022/3/13 17:07
 */


import hadoop.HadoopUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;


@WebServlet("/demo2")
public class Demo2 extends HttpServlet {


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // hdfs 文件读取
        String srcPath =  req.getParameter("srcPath");
        String destPath =  req.getParameter("destPath");
        HadoopUtil hadoopUtil = new HadoopUtil();
        List<String> result  =  hadoopUtil.hadoopRead(srcPath);


        for (int i = 0; i < result.size(); i++) {
            System.out.println(result.get(i));
        }
        req.setAttribute("obj_data",result);

        req.getRequestDispatcher("/queryData.jsp").forward(req,resp);



    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }


}
